home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The 640 MEG Shareware Studio 2
/
The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO
/
clang
/
tcplusx.zip
/
EVENT.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1991-02-18
|
4KB
|
154 lines
//
// event.cpp - implementation for class Event
// Author - Robin W. McKean
// Last Update - February 17,1991
// Copyright (C) 1991 All rights reserved
//
// This file remains the property of the author, Robin W. McKean. You are
// free to use and change it as you see fit. This module, nor its object
// code, may not however be included in any packaged software without the
// written consent of the author.
//
// Contents ----------------------------------------------------------------
//
// Event::Event
// Event::isA
// Event::nameOf
// Event::isEqual
// Event::printOn
//
// Description
//
// Defines the class Event. The purpose of this class is to pass
// information from the program to objects in a uniform manner, no
// matter what the source of the event.
//
// End ---------------------------------------------------------------------
// Interface dependencies --------------------------------------------------
#ifndef _IOSTREAM_H
#include <iostream.h>
#endif
#ifndef _USETYPES_H
#include <usetypes.h>
#endif
#ifndef _GEN_H
#include <gen.h>
#endif
#ifndef _EVENT_H
#include <event.h>
#endif
// End Interface dependencies ----------------------------------------------
// Member Function //
Event::Event( Event& theEvent )
// Description -------------------------------------------------------------
//
// Copies one event into another
//
// Parameters
//
// Event&
//
// The event to be copied
//
// End ---------------------------------------------------------------------
{
type = theEvent.type;
typeCode = theEvent.typeCode;
shiftState = theEvent.shiftState;
}
// End Event::Event( Event& ) //
// Member Function //
classType Event::isA( ) const
// Description -------------------------------------------------------------
//
// Returns a value representation of a class
//
// End ---------------------------------------------------------------------
{
return eventClass;
}
// End Event::isA( ) //
// Member Function //
char *Event::nameOf( ) const
// Description -------------------------------------------------------------
//
// Returns a character representation of a class
//
// End ---------------------------------------------------------------------
{
return "Event";
}
// End Event::nameOf //
// Member Function //
hashValueType Event::hashValue( ) const
// Description -------------------------------------------------------------
//
// Returns a hash value representation of a class, in this case, there
// is none, so we return 0.
//
// End ---------------------------------------------------------------------
{
return hashValueType( 0 );
}
// End Event::hashValue //
int Event::isEqual( const Object& theEvent ) const
// Description -------------------------------------------------------------
//
// Returns a 1 if this object is equal to the event
//
// End ---------------------------------------------------------------------
{
return( ( isA() == theEvent.isA() ) &&
type == ( ( Event& )theEvent ).type &&
typeCode == ( ( Event& )theEvent ).typeCode &&
shiftState == ( ( Event& )theEvent ).shiftState );
}
// End Event::isEqual //
// Member Function //
void Event::printOn( ostream& outputStream ) const
// Description -------------------------------------------------------------
//
// Prints the contents of this object to the outputStream
//
// End ---------------------------------------------------------------------
{
outputStream << "Type: ";
if( type == E_KEY ) outputStream << "Key\n";
else outputStream << "Mouse\n";
outputStream << "Code: " << hex << "0x" << typeCode << "\n";
outputStream << "Shift State: " << "0x" << shiftState << dec << "\n";
}
// End Event::printOn //